package com.aso114.project.mvp;

import android.content.Context;
import android.content.SharedPreferences;

import com.aso114.project.base.BaseApplication;

/**
 * Created by asus on 2018/11/27.
 */

public class LoginSP {
    private static final String DEFAULT_NAME = "login";
    private static LoginSP sInstance = null;
    private SharedPreferences spf = null;
    private SharedPreferences.Editor editor = null;

    private String userId = "userId";
    private String userName = "userName";
    private String userMobile = "userMobile";
    private String userEmail = "userEmail";
    private String userAreaId = "userAreaId";



    private String cityname = "cityname";
    private String userLitpic = "userLitpic";
    private String token = "token";
    private String first = "first";
    private String firsttost = "firsttost";
    private String isSkip = "isSkip";
    private String isBanner = "isBanner";
    private LoginSP() {
        spf = BaseApplication.getInstance().getSharedPreferences(DEFAULT_NAME, Context.MODE_PRIVATE);
        editor = spf.edit();
    }

    public synchronized static LoginSP getInstance() {
        if (sInstance == null) {
            sInstance = new LoginSP();
        }
        return sInstance;
    }

    public boolean isBanner(){
        return spf.getBoolean(isBanner, false);
    }

    public void setBanner(boolean skip){
        spf.edit().putBoolean(isBanner, skip).commit();
    }
    public boolean isSkip(){
        return spf.getBoolean(isSkip, false);
    }

    public void setSkip(boolean skip){
        spf.edit().putBoolean(isSkip, skip).commit();
    }


    public int getUserId() {
        return spf.getInt(userId, 0);
    }

    public void setUserId(int user) {
        spf.edit().putInt(userId, user).commit();
    }

    public String getUserName() {
        return spf.getString(userName, "");
    }

    public void setUserName(String name) {
        spf.edit().putString(userName, name).commit();
    }


    public String getFirst() {
        return spf.getString(first, "");
    }

    public void setFirst(String name) {
        spf.edit().putString(first, name).commit();
    }

    public String getFirstTost() {
        return spf.getString(firsttost, "");
    }

    public void setFirstTost(String tost) {
        spf.edit().putString(firsttost, tost).commit();
    }

    public String getUserMobile() {
        return spf.getString(userMobile, "");
    }

    public void setUserMobile(String mobile) {
        spf.edit().putString(userMobile, mobile).commit();
    }

    public String getUserEmail() {
        return spf.getString(userEmail, "");
    }

    public void setUserEmail(String email) {
        spf.edit().putString(userEmail, email).commit();
    }

    public String getUserAreaId() {
        return spf.getString(userAreaId, "");
    }

    public void setUserAreaId(String areaId) {
        spf.edit().putString(userAreaId, areaId).commit();
    }

    public String getCityname() {
        return spf.getString(cityname, "");
    }

    public void setCityname(String citynames) {
        spf.edit().putString(cityname, citynames).commit();
    }

    public String getUserLitpic() {
        return spf.getString(userLitpic, "");
    }

    public void setUserLitpic(String litpic) {
        spf.edit().putString(userLitpic, litpic).commit();
    }

    public String getToken() {
        return spf.getString(token, "");
    }

    public void setToken(String toke) {
        spf.edit().putString(token, toke).commit();
    }
}
